<template>
  <div>
    <h3>接收到的消息：</h3>
    <p id="component2content"></p>
  </div>
</template>

<script>
export default {
  name: 'Component2',
  mounted () {
    window.addEventListener('message', function (ev) {
      console.log(ev.data, '可拖拽组件收到消息')
      document.getElementById('component2content').innerHTML += new Date().toLocaleString() + '：<br>' + JSON.stringify(ev.data) + '<br><br>'
    })
  }
}
</script>

<style scoped>
  h3 {
    margin: 0;
    font-weight: normal;
  }
</style>
